﻿from django.test import TestCase
from django.test.client import Client
from django.contrib.auth.models import User

class SimpleTest(TestCase):
    def setUp(self):
    
        self.user = User.objects.create_user('tester', 'tester@homemail.ru', '123')
    
        self.login_req_uris=[
            '/echo/',      
            '/echo/result/%s/$', 
            '/echo/toftp/%s/$',   
            '/echo/authors/$',         
            '/echo/items/$',     
            '/echo/item/%s/edit/$',  
            #'/echo/author/%s/item/%s/edit/$',
            '/echo/edit/%s/$',]
        self.no_login_req_uris = ['/']
        self.client = Client()
        self.logged_client = Client()
        self.logged_client.login(username='john', password='abc')


    def test_login_required_URLs(self):
        for uri in self.login_req_uris:
            if '%s' in uri:
                uri = uri % 1 
            response = self.client.get(uri)
            self.failUnlessEqual(response.status_code, 302)